<!DOCTYPE html>

<html lang="en">
<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  <meta name="baidu-site-verification" content="GOgEP8c1pN"/>
  

  <title>
    让 Django 完成翻译：迁移数据库_Django博客教程_追梦人物的博客</title>

  <link href="font-awesome.min.css"
        rel="stylesheet">
  <link rel="stylesheet" href="mobi.min.css">
  <link rel="stylesheet" href="modal.min.css">
  <link rel="stylesheet" href="friendly.css">
  <link rel="stylesheet" href="blog.css?v0.12">
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script src="/static/blog/js/menu.js"></script>
  <script src="/static/blog/js/modal.min.js"></script>
  <script src="/static/blog/js/blog.js"></script>
  

  
    <script>
        // baidu statistics
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?fb59b2a6022bccc02671a750f61c356b";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();

        // baidu auto push
        (function () {
            var bp = document.createElement('script');
            var curProtocol = window.location.protocol.split(':')[0];
            if (curProtocol === 'https') {
                bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
            }
            else {
                bp.src = 'http://push.zhanzhang.baidu.com/push.js';
            }
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(bp, s);
        })();
    </script>
    
  
</head>
<body class="bg-light">
<header>
  <nav class="flex-center bg-white nav-bar">
    <div class="container-wider flex-middle">
      
  <a class="show-on-mobile nav-link m-5" id="js-sidebar-btn" href="#" role="button">
    <i class="fa fa-chevron-right" aria-hidden="true"></i>
  </a>

      <a class="nav-bar-logo mr-7" href="/">
        <img src="/static/blog/images/logo.png" alt="blog logo">
      </a>
      <ul class="unit-0 hide-on-mobile nav-bar-nav">
        <li class="nav-item mr-7">
          <a class="nav-link" href="/">首页</a>
        </li>
        <li class="nav-item mr-7">
          <a class="nav-link" href="/tutorials/">教程</a>
        </li>
        <li class="nav-item mr-7">
          <a class="nav-link" href="/categories/">分类</a>
        </li>
        <li class="nav-item mr-7">
          <a class="nav-link" href="/archives/">归档</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/donate/">赞助</a>
        </li>
      </ul>
      <div class="unit flex-right flex-middle">
        <form class="hide-on-mobile flex-left flex-middle search-form mr-5" id="search-form"
              action="/search/">
          <input class="unit" type="search" name="q" placeholder="搜索..."/>
          <button class="unit-0" type="submit" role="button">
            <i class="fa fa-search" aria-hidden="true"></i>
          </button>
        </form>
        <a class="show-on-mobile nav-link fs-7 mr-7" id="js-search-btn" href="#" role="button">
          <i class="fa fa-search" aria-hidden="true"></i>
        </a>
        <div class="flex-middle notification">
          
            <a class="nav-link" href="/accounts/login/">
              <i class="fa fa-sign-in" aria-hidden="true"></i>
            </a>
          
        </div>
        <div class="show-on-mobile flex-middle">
          <a class="nav-link fs-7 ml-7 mr-5" id="menu-toggle" href="#">
            <i class="fa fa-ellipsis-v" aria-hidden="true"></i>
          </a>
          <ul class="menu bg-white" data-menu data-menu-toggle="#menu-toggle">
            <li class="nav-item mr-7">
              <a class="nav-link" href="/">首页</a>
            </li>
            <li>
              <a href="/tutorials/">教程</a>
            </li>
            <li>
              <a href="/categories/">分类</a>
            </li>
            <li>
              <a href="/archives/">归档</a>
            </li>
            <li>
              <a href="/donate/">赞助</a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </nav>
</header>
<section class="flex-center">
  <div class="container-wider">
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
              &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">设置评论回复接收邮箱</h4>
            <div class="text-primary mt-2">邮箱仅用于接收回复提醒，不会被公开。</div>
            
          </div>
          <div class="modal-body">
            <form class="form email-binding-form" action="/comments/ajax_email_binding/">
              <div class="message">
                <span class="text-danger"></span>
              </div>
              <input type='hidden' name='csrfmiddlewaretoken' value='MTLZjn2GknvDEdGgVNWVsG9O9MzRQROLBhOLVd1VcCfbajhaDjT6cVKEpI4cMpU1' />
              <div class="flex-left units-gap">
                <label class="unit-0 text-right" for="multiple-inputs-name">邮箱: </label>
                <div class="unit">
                  <input type="email" name="email" id="id_email" placeholder="请输入绑定邮箱"/>
                </div>
                <div class="unit-0">
                  <button class="btn" id="js-send" type="button"
                          data-target="/comments/ajax_verification_code/">发送验证码
                  </button>
                </div>
              </div>
              <div class="flex-left units-gap">
                <label class="unit-0 text-right" for="multiple-inputs-name">验证码: </label>
                <div class="unit">
                  <input type="text" name="verification_code" id="id_verification_code"
                         placeholder="请输入接收到的验证码"/>
                </div>
              </div>
              <div class="flex-right">
                <button type="button" class="btn btn-danger mr-3" data-dismiss="modal">关闭</button>
                <button type="submit" class="btn btn-primary" id="js-submit">设置</button>
              </div>
            </form>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal -->
    </div>
    <div class="flex-left flex-wrap "
         style="margin-top: 60px">
      
  <aside class="unit-1-4 unit-1-on-mobile top-gap">
    <div class="scroll-view bg-white card toc-sidebar" style="height: 100%">
      <div class="card-header">
        目录
      </div>
      <div class="flex-left">
        <div class="unit-1-4">
          <a href="https://promotion.aliyun.com/ntms/act/group/team.html?group=FcfAncJPAp" target="_blank"><img
              src="/static/blog/images/aliyun.jpg" alt=""></a>
        </div>
        <div class="unit-1-2 flex-vertical top-gap text-small">
          <a style="color: #e83e8c" target="_blank"
             href="https://promotion.aliyun.com/ntms/act/group/team.html?group=FcfAncJPAp">云服务器新用户</a>
          <a style="color: #6610f2" target="_blank"
             href="https://promotion.aliyun.com/ntms/act/group/team.html?group=FcfAncJPAp">8元/月</a>
        </div>
      </div>
      <div class="card-body">
        <ul>
          <li>
            <h6 class="top-gap-0"><a href="">Django博客教程</a></h6>
            <ul>
              
                <li>
                  <a href="2.html">前言</a>
                  
                </li>
              
                <li>
                  <a href="3.html">搭建开发环境</a>
                  
                </li>
              
                <li>
                  <a href="4.html">建立 Django 博客应用</a>
                  
                </li>
              
                <li>
                  <a href="5.html">创建 Django 博客的数据库模型</a>
                  
                </li>
              
                <li>
                  <a href="6.html">让 Django 完成翻译：迁移数据库</a>
                  
                    <div class="toc">
<ul>
<li><a href="#迁移数据库">迁移数据库</a></li>
<li><a href="#选择数据库版本">选择数据库版本</a></li>
<li><a href="#用-django-的方式操作数据库">用 Django 的方式操作数据库</a><ul>
<li><a href="#存数据">存数据</a></li>
<li><a href="#取数据">取数据</a></li>
<li><a href="#改数据">改数据</a></li>
<li><a href="#删数据">删数据</a></li>
</ul>
</li>
<li><a href="#总结">总结</a></li>
</ul>
</div>

                  
                </li>
              
                <li>
                  <a href="7.html">Django 博客首页视图</a>
                  
                </li>
              
                <li>
                  <a href="8.html">真正的 Django 博客首页视图</a>
                  
                </li>
              
                <li>
                  <a href="9.html">在 Django Admin 后台发布文章</a>
                  
                </li>
              
                <li>
                  <a href="10.html">博客文章详情页</a>
                  
                </li>
              
                <li>
                  <a href="11.html">支持 Markdown 语法和代码高亮</a>
                  
                </li>
              
                <li>
                  <a href="12.html">页面侧边栏：使用自定义模板标签</a>
                  
                </li>
              
                <li>
                  <a href="13.html">分类与归档</a>
                  
                </li>
              
                <li>
                  <a href="14.html">评论</a>
                  
                </li>
              
                <li>
                  <a href="16.html">已知小问题修正</a>
                  
                </li>
              
                <li>
                  <a href="20.html">使用 Nginx 和 Gunicorn 部署 Django 博客</a>
                  
                </li>
              
                <li>
                  <a href="21.html">使用 Fabric 自动化部署</a>
                  
                </li>
              
                <li>
                  <a href="29.html">统计文章阅读量</a>
                  
                </li>
              
                <li>
                  <a href="32.html">自动生成文章摘要</a>
                  
                </li>
              
                <li>
                  <a href="33.html">基于类的通用视图：ListView 和 DetailView</a>
                  
                </li>
              
                <li>
                  <a href="34.html">Django Pagination 简单分页</a>
                  
                </li>
              
                <li>
                  <a href="37.html">Django Pagination 完善分页</a>
                  
                </li>
              
                <li>
                  <a href="38.html">统计各个分类下的文章数</a>
                  
                </li>
              
                <li>
                  <a href="39.html">标签云</a>
                  
                </li>
              
                <li>
                  <a href="41.html">RSS 订阅</a>
                  
                </li>
              
                <li>
                  <a href="43.html">Markdown 自动生成文章目录</a>
                  
                </li>
              
                <li>
                  <a href="44.html">简单全文搜索</a>
                  
                </li>
              
                <li>
                  <a href="45.html">Django Haystack 全文检索与关键词高亮</a>
                  
                </li>
              
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </aside>

      
  <div class="unit-3-4 unit-1-on-mobile top-gap">
    


<div class="bg-white card post-card px-7 py-5">
  
<article class="post">
  <h1 class="top-gap-0">让 Django 完成翻译：迁移数据库</h1>
  <ul class="list-inline dot-divider post-meta">
    <li class="list-inline-item text-small text-muted">
      12 月前
    </li>
    <li class="list-inline-item text-small text-muted">8730 字
    </li>
    <li class="list-inline-item text-small text-muted">
      37500 阅读
    </li>
    <li class="list-inline-item text-small text-muted">
      128 评论
    </li>
  </ul>
  <div class="top-gap-big post-body">
    <p>我们已经编写了博客数据库模型的代码，但那还只是 Python 代码而已，Django 还没有把它翻译成数据库语言，因此实际上这些数据库表还没有真正的在数据库中创建。</p>
<h2 id="迁移数据库">迁移数据库</h2>
<p>为了让 Django 完成翻译，创建好这些数据库表，我们再一次请出我的工程管理助手 manage.py。<strong>激活虚拟环境</strong>，切换到 manage.py 文件所在的目录下，分别运行 <code>python manage.py makemigrations</code> 和 <code>python manage.py migrate</code> 命令：</p>
<div class="codehilite"><pre><span></span>C:\WINDOWS\system32&gt;C:\Users\yangxg\Envs\blogproject_env\Scripts\activate

(blogproject_env) C:\WINDOWS\system32&gt;cd C:\Users\yangxg\Workspace\blogproject

(blogproject_env) C:\Users\yangxg\Workspace\blogproject&gt;python manage.py makemigrations
Migrations for &#39;blog&#39;:
  blog\migrations\0001_initial.py:
    - Create model Category
    - Create model Post
    - Create model Tag
    - Add field tags to post

(blogproject_env) C:\Users\yangxg\Workspace\blogproject&gt;python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying blog.0001_initial... OK
  Applying sessions.0001_initial... OK
</pre></div>


<p><strong>注意：如果代码中含有中文注释，且你使用的是 Python 2 开发环境的话，会得到一个编码错误。因此请在含有中文注释的文件最开始处加入编码声明：# coding: utf-8。</strong></p>
<p>当我们执行了 <code>python manage.py makemigrations</code> 后，Django 在 blog 应用的 migrations\ 目录下生成了一个 0001_initial.py 文件，这个文件是 Django 用来记录我们对模型做了哪些修改的文件。目前来说，我们在 models.py 文件里创建了 3 个模型类，Django 把这些变化记录在了 0001_initial.py 里。</p>
<p>不过此时还只是告诉了 Django 我们做了哪些改变，为了让 Django 真正地为我们创建数据库表，接下来又执行了 <code>python manage.py migrate</code> 命令。Django 通过检测应用中 migrations\ 目录下的文件，得知我们对数据库做了哪些操作，然后它把这些操作翻译成数据库操作语言，从而把这些操作作用于真正的数据库。</p>
<p>你可以看到命令的输出除了 Applying blog.0001_initial... OK 外，Django 还对其它文件做了操作。这是因为除了我们自己建立的 blog 应用外，Django 自身还内置了很多应用，这些应用本身也是需要存储数据的。可以在 settings.py 的 <code>INSTALLED_APP</code> 设置里看到这些应用，当然我们目前不必关心这些。</p>
<div class="codehilite"><pre><span></span><span class="n">blogproject</span><span class="o">/</span><span class="n">settings</span><span class="o">.</span><span class="n">py</span>

<span class="n">INSTALLED_APPS</span> <span class="o">=</span> <span class="p">[</span>
    <span class="s1">&#39;django.contrib.admin&#39;</span><span class="p">,</span>
    <span class="s1">&#39;django.contrib.auth&#39;</span><span class="p">,</span>
    <span class="s1">&#39;django.contrib.contenttypes&#39;</span><span class="p">,</span>
    <span class="s1">&#39;django.contrib.sessions&#39;</span><span class="p">,</span>
    <span class="s1">&#39;django.contrib.messages&#39;</span><span class="p">,</span>
    <span class="s1">&#39;django.contrib.staticfiles&#39;</span><span class="p">,</span>
    <span class="s1">&#39;blog&#39;</span><span class="p">,</span>
<span class="p">]</span>
</pre></div>


<p>对于了解数据库语言的人，你可以运行下面的命令看看 Django 究竟为我们做了什么：</p>
<div class="codehilite"><pre><span></span>python manage.py sqlmigrate blog 0001
</pre></div>


<p>你将看到输出了经 Django 翻译后的数据库表创建语句，这有助于你理解 Django  ORM 的工作机制。</p>
<h2 id="选择数据库版本">选择数据库版本</h2>
<p>我们没有安装任何的数据库软件，Django 就帮我们迁移了数据库。这是因为我们使用了 Python 内置的 SQLite3 数据库。</p>
<p>SQLite3 是一个十分轻巧的数据库，它仅有一个文件。你可以看一到项目根目录下多出了一个 db.sqlite3 的文件，这就是 SQLite3 数据库文件，Django 博客的数据都会保存在这个数据库文件里。</p>
<p>Django 在 settings.py 里为我们做了一些默认的数据库配置：</p>
<div class="codehilite"><pre><span></span><span class="n">blogproject</span><span class="o">/</span><span class="n">settings</span><span class="o">.</span><span class="n">py</span>

<span class="c1">## 其它配置选项...</span>
<span class="n">DATABASES</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s1">&#39;default&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s1">&#39;ENGINE&#39;</span><span class="p">:</span> <span class="s1">&#39;django.db.backends.sqlite3&#39;</span><span class="p">,</span>
        <span class="s1">&#39;NAME&#39;</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">BASE_DIR</span><span class="p">,</span> <span class="s1">&#39;db.sqlite3&#39;</span><span class="p">),</span>
    <span class="p">}</span>
<span class="p">}</span>
<span class="c1">## 其它配置选项...</span>
</pre></div>


<p>可以看到默认的数据库引擎就是使用的 SQLite3。</p>
<p>当然一些人倾向于使用 MySQL 等大型数据库，至于 Django 如何配置 MySQL 这里就不赘述了，你可以自行使用搜索引擎或者查阅 Django 的官方文档解决。对于一个小型博客而言，SQLite3 数据库足以胜任。</p>
<h2 id="用-django-的方式操作数据库">用 Django 的方式操作数据库</h2>
<p>数据库最主要的操作就是往里面存入数据、从中取出数据、修改已保存的数据和删除不再需要的数据。和创建数据库表一样，Django 为这些操作提供了一整套方法，从而把我们从数据库语言中解放出来。我们不用学习如何利用数据库语言去完成这些操作，只要简单地调用几个 Python 函数就可以满足我们的需求。</p>
<h3 id="存数据">存数据</h3>
<p>先在命令行中来探索一下这些函数，感受一下如何用 Django 的方式来操作数据库。在 manage.py 所在目录下运行 <code>python manage.py shell</code> 命令：</p>
<div class="codehilite"><pre><span></span>(blogproject_env) C:\Users\yangxg\Workspace\blogproject&gt;python manage.py shell
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
(InteractiveConsole)
&gt;&gt;&gt;
</pre></div>


<p>这打开了一个交互式命令行。</p>
<p>首先我们来创建一个分类和一个标签：</p>
<div class="codehilite"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">blog.models</span> <span class="kn">import</span> <span class="n">Category</span><span class="p">,</span> <span class="n">Tag</span><span class="p">,</span> <span class="n">Post</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">c</span> <span class="o">=</span> <span class="n">Category</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;category test&#39;</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">c</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;tag test&#39;</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">t</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
</pre></div>


<p>我们首先导入 3  个之前写好的模型类，然后实例化了一个 <code>Category</code> 类和一个 <code>Tag</code> 类，为他们的属性 <code>name</code> 赋了值。为了让 Django 把这些数据保存进数据库，调用实例的 <code>save</code> 方法即可。</p>
<p>再创建一篇文章试试，但创建文章之前，我们需要先创建一个 User，用于指定文章的作者。创建 User 的命令 Django 已经帮我们写好了，依然是通过 manage.py 来运行。首先按住 Ctrl + c 退出命令交互栏（一次退不出就连续多按几次），运行 <code>python manage.py createsuperuser</code> 命令并根据提示创建用户：</p>
<div class="codehilite"><pre><span></span><span class="p">(</span><span class="n">blogproject_env</span><span class="p">)</span> <span class="nl">C</span><span class="p">:</span><span class="err">\</span><span class="n">Users</span><span class="err">\</span><span class="n">yangxg</span><span class="err">\</span><span class="n">Workspace</span><span class="err">\</span><span class="n">blogproject</span><span class="o">&gt;</span><span class="n">python</span> <span class="n">manage</span><span class="p">.</span><span class="n">py</span> <span class="n">createsuperuser</span>
<span class="n">Username</span> <span class="p">(</span><span class="n">leave</span> <span class="n">blank</span> <span class="n">to</span> <span class="n">use</span> <span class="err">&#39;</span><span class="n">zmrenwu</span><span class="mf">@163.</span><span class="n">com</span><span class="err">&#39;</span><span class="p">)</span><span class="o">:</span> <span class="n">myuser</span>
<span class="n">Email</span> <span class="nl">address</span><span class="p">:</span> <span class="n">a</span><span class="p">@</span><span class="n">aa</span><span class="p">.</span><span class="n">com</span>
<span class="nl">Password</span><span class="p">:</span>
<span class="n">Password</span> <span class="p">(</span><span class="n">again</span><span class="p">)</span><span class="o">:</span>
<span class="n">Superuser</span> <span class="n">created</span> <span class="n">successfully</span><span class="p">.</span>
</pre></div>


<p>运行 <code>python manage.py createsuperuser</code> 开始创建用户，之后会提示你输入用户名、邮箱、密码和确认密码，按照提示输入即可。<strong>注意一点的是密码输入过程中不会有任何字符显示，不要误以为你的键盘出问题了，正常输入即可。</strong>最后出现 Superuser created successfully. 说明用户创建成功了。</p>
<p>再次运行 <code>python manage.py shell</code> 进入 Python 命令交互栏，开始创建文章：</p>
<div class="codehilite"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">blog.models</span> <span class="kn">import</span> <span class="n">Category</span><span class="p">,</span> <span class="n">Tag</span><span class="p">,</span> <span class="n">Post</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">django.utils</span> <span class="kn">import</span> <span class="n">timezone</span>
<span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">django.contrib.auth.models</span> <span class="kn">import</span> <span class="n">User</span>

<span class="o">&gt;&gt;&gt;</span> <span class="n">user</span> <span class="o">=</span> <span class="n">User</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">username</span><span class="o">=</span><span class="s1">&#39;myuser&#39;</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">c</span> <span class="o">=</span> <span class="n">Category</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;category test&#39;</span><span class="p">)</span>

<span class="o">&gt;&gt;&gt;</span> <span class="n">p</span> <span class="o">=</span> <span class="n">Post</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">&#39;title test&#39;</span><span class="p">,</span> <span class="n">body</span><span class="o">=</span><span class="s1">&#39;body test&#39;</span><span class="p">,</span> <span class="n">created_time</span><span class="o">=</span><span class="n">timezone</span><span class="o">.</span><span class="n">now</span><span class="p">(),</span> <span class="n">modified_time</span><span class="o">=</span><span class="n">timezone</span><span class="o">.</span><span class="n">now</span><span class="p">(),</span> <span class="n">category</span><span class="o">=</span><span class="n">c</span><span class="p">,</span> <span class="n">author</span><span class="o">=</span><span class="n">user</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">p</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
</pre></div>


<p>由于我们重启了 shell，因此需要重新导入了 <code>Category</code>、<code>Tag</code>、<code>Post</code> 以及 <code>User</code>。我们还导入了一个 Django 提供的辅助模块 timezone，这是因为我们需要调用它的 <code>now()</code> 方法为 <code>created_time</code> 和 <code>modified_time</code> 指定时间，容易理解 <code>now</code> 方法返回当前时间。然后我们根据用户名和分类名，通过 <code>get</code> 方法取出了存在数据库中的 <code>User</code> 和 <code>Category</code>（取数据的方法将在下面介绍）。接着我们为文章指定了 <code>title</code>、<code>body</code> 、<code>created_time</code>、<code>modified_time</code>值，并把它和前面创建的 Category 以及 User 关联了起来。允许为空 <code>excerpt</code>、<code>tags</code> 我们就没有为它们指定值了。</p>
<p><strong>注意：我们这里使用 <code>get</code> 方法根据 <code>Category</code> 的 <code>name</code> 属性的值获取分类的一条记录。<code>Category.objects.get(name='category test')</code> 的含义是从数据库中取出 <code>name</code> 的值为 category test 的分类记录。确保数据库中只有一条值为 category test 的记录，否则 <code>get</code> 方法将返回一个 <code>MultipleObjectsReturned</code> 异常。如果你不小心已经存了多条记录，请删掉多余的记录。如何删除数据请看下文。</strong></p>
<h3 id="取数据">取数据</h3>
<p>数据已经存入数据库了，现在要把它们取出来看看：</p>
<div class="codehilite"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="n">Category</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Category</span><span class="p">:</span> <span class="n">Category</span> <span class="nb">object</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Tag</span><span class="p">:</span> <span class="n">Tag</span> <span class="nb">object</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Post</span><span class="p">:</span> <span class="n">Post</span> <span class="nb">object</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>
<span class="o">&gt;&gt;&gt;</span>
</pre></div>


<p><code>objects</code> 是我们的模型管理器，它为我们提供一系列从数据库中取数据方法，这里我们使用了 <code>all</code> 方法，表示我们要把对应的数据全部取出来。可以看到 <code>all</code> 方法都返回了数据，这些数据应该是我们之前存进去的，但是显示的字符串有点奇怪，无法看出究竟是不是我们之前存入的数据。为了让显示出来的数据更加人性化一点，我们为 3 个模型分别增加一个 <code>__str__</code> 方法：</p>
<div class="codehilite"><pre><span></span><span class="n">blog</span><span class="o">/</span><span class="n">models</span><span class="o">.</span><span class="n">py</span>

<span class="kn">from</span> <span class="nn">django.utils.six</span> <span class="kn">import</span> <span class="n">python_2_unicode_compatible</span>

<span class="c1"># python_2_unicode_compatible 装饰器用于兼容 Python2</span>
<span class="nd">@python_2_unicode_compatible</span>
<span class="k">class</span> <span class="nc">Category</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>

<span class="nd">@python_2_unicode_compatible</span>
<span class="k">class</span> <span class="nc">Tag</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>

<span class="nd">@python_2_unicode_compatible</span>
<span class="k">class</span> <span class="nc">Post</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span>
</pre></div>


<p>定义好 <code>__str__</code> 方法后，解释器显示的内容将会是 <code>__str__</code> 方法返回的内容。这里 <code>Category</code> 返回分类名 <code>name</code> ，<code>Tag</code> 返回标签名，而 <code>Post</code> 返回它的 <code>title</code>。</p>
<p><code>python_2_unicode_compatible</code> 装饰器用于兼容 Python2。如果你使用的 Python3 开发环境，去掉这个装饰器不会有任何影响。如果你使用的 Python2 开发环境，而又不想使用这个装饰器，则将 <code>__str__</code> 方法改为 <code>__unicode__</code> 方法即可。</p>
<p>先按 Ctrl + c 退出 Shell，再重新运行 <code>python manage.py shell</code> 进入 Shell。</p>
<div class="codehilite"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">blog.models</span> <span class="kn">import</span> <span class="n">Category</span><span class="p">,</span> <span class="n">Tag</span><span class="p">,</span> <span class="n">Post</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Category</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Category</span><span class="p">:</span> <span class="n">category</span> <span class="n">test</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>

<span class="o">&gt;&gt;&gt;</span> <span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Tag</span><span class="p">:</span> <span class="n">tag</span> <span class="n">test</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>

<span class="o">&gt;&gt;&gt;</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Post</span><span class="p">:</span> <span class="n">title</span> <span class="n">test</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>

<span class="o">&gt;&gt;&gt;</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">&#39;title test&#39;</span><span class="p">)</span>
<span class="o">&lt;</span><span class="n">Post</span><span class="p">:</span> <span class="n">title</span> <span class="n">test</span><span class="o">&gt;</span>
</pre></div>


<p>可以看到返回的是我们之前存入的数据。</p>
<p>此外我们在创建文章时提到了通过 <code>get</code> 方法来获取数据，这里 <code>all</code> 方法和 <code>get</code> 方法的区别是：<code>all</code> 方法返回全部数据，是一个类似于列表的数据结构（QuerySet）；而 <code>get</code> 返回一条记录数据，如有多条记录或者没有记录，<code>get</code> 方法均会抛出相应异常。</p>
<h3 id="改数据">改数据</h3>
<p>尝试修改数据：</p>
<div class="codehilite"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="n">c</span> <span class="o">=</span> <span class="n">Category</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;category test&#39;</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">c</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">&#39;category test new&#39;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">c</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Category</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">Category</span><span class="p">:</span> <span class="n">test</span> <span class="n">category</span> <span class="n">new</span><span class="o">&gt;</span><span class="p">]</span><span class="o">&gt;</span>
</pre></div>


<p>首先通过 <code>get</code> 方法根据分类名 <code>name</code> 获取值为 category test 到分类，修改它的 <code>name</code> 属性为新的值 category test new，然后调用 <code>save</code> 方法把修改保存到数据库，之后可以看到数据库返回的数据已经是修改后的值了。<code>Tag</code>、<code>Post</code> 的修改也一样。</p>
<h3 id="删数据">删数据</h3>
<p>删除掉数据：</p>
<div class="codehilite"><pre><span></span><span class="o">&gt;&gt;&gt;</span> <span class="n">p</span> <span class="o">=</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">&#39;title test&#39;</span><span class="p">)</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">p</span>
<span class="o">&lt;</span><span class="n">Post</span><span class="p">:</span> <span class="n">title</span> <span class="n">test</span><span class="o">&gt;</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">p</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
<span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;blog.Post_tags&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;blog.Post&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
<span class="o">&gt;&gt;&gt;</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
<span class="o">&lt;</span><span class="n">QuerySet</span> <span class="p">[]</span><span class="o">&gt;</span>
</pre></div>


<p>先根据标题 <code>title</code> 的值从数据库中取出 <code>Post</code>，保存在变量 <code>p</code> 中，然后调用它的<code>delete</code> 方法，最后看到 <code>Post.objects.all()</code> 返回了一个空的 QuerySet（类似于一个列表），表明数据库中已经没有 Post，Post 已经被删除了。</p>
<p>这就是 Django 对数据库增、删、改、查的操作。除了上述演示的方法外，Django 还为我们提供了大量其它的方法，这些方法有一部分会在教程中使用，用到时我会讲解它们的用法。但以后你开发自己的项目时，你就需要通过阅读 <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/">Django 的官方文档</a> 来了解有哪些方法可用以及如何使用它们。</p>
<h2 id="总结">总结</h2>
<p>本章节的代码位于：<a href="https://github.com/zmrenwu/django-blog-tutorial/tree/Step4_make-migrations-and-migrate">Step4: make migrations and migrate</a>。</p>
<p>如果遇到问题，请通过下面的方式寻求帮助。</p>
<ul>
<li>在下方评论区留言。</li>
<li>将问题的详细描述通过邮件发送到 djangostudyteam@163.com，一般会在 24 小时内回复。</li>
<li>在 <a href="http://www.pythonzh.cn/category/newbie-qa/">Pythonzhcn 社区的新手问答版块</a> 发布帖子。</li>
</ul>
    <p class="text-center">
      -- EOF --
    </p>
    <div>
      <button class="btn btn-primary" id="js-reward"><i class="fa fa-jpy"
                                                        aria-hidden="true"></i>
        如果觉得文章对你有帮助，请随意打赏
        <i class="fa fa-chevron-down" aria-hidden="true"></i>
      </button>
      <div class="flex-left flex-wrap units-gap-big mt-4" style="display: none">
        <div class="unit unit-1-on-mobile flex-center">
          <figure>
            <img src="/static/blog/images/weixinpay.jpg" alt="微信支付收款二维码"
                 style="width: 250px">
            <figcaption class="text-center fs-6 mt-2" style="color: green">微信</figcaption>
          </figure>
        </div>
        <div class="unit unit-1-on-mobile flex-center">
          <figure>
            <img src="/static/blog/images/alipay.jpg" alt="支付宝收款二维码" style="width: 250px">
            <figcaption class="text-center fs-6 mt-2 text-primary">支付宝</figcaption>
          </figure>
        </div>
      </div>
    </div>
    <div class="post-tags">
      <ul class="list-inline">
        
      </ul>
    </div>
  </div>
</article>
  <div class="top-gap">
    <div class="jiathis_style">
      <span class="jiathis_txt">分享到：</span>
      <a class="jiathis_button_qzone">QQ空间</a>
      <a class="jiathis_button_tsina">新浪微博</a>
      <a class="jiathis_button_tqq">腾讯微博</a>
      <a class="jiathis_button_weixin">微信</a>
      <a href="http://www.jiathis.com/share?uid=2128865"
         class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis"
         target="_blank">更多</a>
      <a class="jiathis_counter_style"></a>
    </div>
    <script type="text/javascript">
        var jiathis_config = {data_track_clickback: 'true'};
    </script>
    <script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=2128865"
            charset="utf-8"></script>
    <!-- JiaThis Button END -->
  </div>
  <br>
  <div class="top-gap clearfix">
    
      <a href="5.html">
        <i class="fa fa-angle-double-left" aria-hidden="true"></i>
        创建 Django 博客的数据库模型
      </a>
    
    
      <a class="float-right" href="7.html">
        Django 博客首页视图
        <i class="fa fa-angle-double-right" aria-hidden="true"></i>
      </a>
    
  </div>
  

  <section class="comment-area top-gap-big" id="comment-area">
    <h5>128 条评论 / 60 人参与</h5>
    
      
<div class="flex-center top-gap login-panel p-7">
  <div>
    <div class="text-muted text-center login-header"><span>登录后回复</span></div>
    <div class="flex-center text-center social-icons mt-3">
                        <span class="weibo mr-3">
                            <a href="/accounts/weibo/login/">
                                <i class="fa fa-weibo" aria-hidden="true"></i>
                            </a>
                        </span>
      <span class="github">
                            <a href="/accounts/github/login/">
                                <i class="fa fa-github" aria-hidden="true"></i>
                            </a>
                        </span>
    </div>
  </div>
</div>
    
    <div class="top-gap-big comment-list">
  
    <div class="flex-left py-4" id="c2328">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.0.0.750.750.180/0062Je87jw8ey78fdw8oej30ku0kuq46.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Sagittariussun
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主你好,为什么会出现这种状况啊,求解决</p><p>&gt;&gt;&gt; Post.objects.all()&lt;QuerySet [&lt;Post: Post object&gt;, &lt;Post: Post object&gt;]&gt;<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2328"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2309">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/34994982?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">wenthomas
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主您好，我想问一下我的时区已经做好了配置修改，但是在这一章创建了数据后进blog_post文章表发现created_time和modified_time还是UTC时间，并没有正确显示中国时区，请问这个是怎么回事？</p><p>settings.py :</p><pre><code class="lang-python">LANGUAGE_CODE = 'zh-Hans'<br />TIME_ZONE = 'Asia/Shanghai'<br />USE_I18N = True<br />USE_L10N = True<br />USE_TZ = True<br></code></pre>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2309"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2231">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/11845936?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">fans
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>t = Tag(name='tag test')执行时报错：<br></p><p>&nbsp;TypeError: __init__() got an unexpected keyword argument 'name'<br></p><p>检查数据库，是有这个字段的，可以用sql插入数据，这是什么原因？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2231"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2200">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/15277388?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">passer-byzhang
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主您好，我在</p><p>&gt;&gt;&gt;from blog.models import Category, Tag, Post&nbsp;</p><p>&gt;&gt;&gt; c = Category(name='category test')</p><p>&nbsp;&gt;&gt;&gt; c.save()</p><p>&nbsp;&gt;&gt;&gt; t = Tag(name='tag test')</p><p>&nbsp;&gt;&gt;&gt; t.save() &nbsp;之后 &nbsp; CTRL-C进行保存，报了如下错误<br>Traceback (most recent call last):&nbsp; File "manage.py", line 22, in &lt;module&gt;&nbsp; &nbsp; execute_from_command_line(sys.argv)&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line&nbsp; &nbsp; utility.execute()&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\core\management\__init__.py", line 359, in execute&nbsp; &nbsp; self.fetch_command(subcommand).run_from_argv(self.argv)&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\core\management\base.py", line 306, in run_from_argv&nbsp; &nbsp; connections.close_all()&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\db\utils.py", line 234, in close_all&nbsp; &nbsp; connection.close()&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\db\backends\sqlite3\base.py", line 235, in close&nbsp; &nbsp; BaseDatabaseWrapper.close(self)&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\db\backends\base\base.py", line 272, in close&nbsp; &nbsp; self._close()&nbsp; File "C:\Users\pc\blog\blogproject_env\lib\site-packages\django\db\backends\base\base.py", line 221, in _close&nbsp; &nbsp; return self.connection.close()KeyboardInterrupt<br></p><p>这说明我的哪个步骤没有配置好啊</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2200"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2314">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/16523156?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">lamber
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">passer-byzhang
        

  </header>
  <div class="comment-body">
    <p>你别用ctrl+c啊。。那样直接就跳出去了，你看你报错KeyBoardInterrupt</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2314"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2187">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/35491043?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Blake Peng
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主，我遇到了这个问题：</p><p>Traceback (most recent call last):&nbsp; File "manage.py", line 15, in &lt;module&gt;&nbsp; &nbsp; execute_from_command_line(sys.argv)&nbsp; File "F:\Envs\blogproject_env\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line&nbsp; &nbsp; utility.execute()&nbsp; File "F:\Envs\blogproject_env\lib\site-packages\django\core\management\__init__.py", line 347, in execute&nbsp; &nbsp; django.setup()&nbsp; File "F:\Envs\blogproject_env\lib\site-packages\django\__init__.py", line 24, in setup&nbsp; &nbsp; apps.populate(settings.INSTALLED_APPS)&nbsp; File "F:\Envs\blogproject_env\lib\site-packages\django\apps\registry.py", line 112, in populate&nbsp; &nbsp; app_config.import_models()&nbsp; File "F:\Envs\blogproject_env\lib\site-packages\django\apps\config.py", line 198, in import_models&nbsp; &nbsp; self.models_module = import_module(models_module_name)&nbsp; File "F:\Envs\blogproject_env\lib\importlib\__init__.py", line 126, in import_module&nbsp; &nbsp; return _bootstrap._gcd_import(name[level:], package, level)&nbsp; File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import&nbsp; File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load&nbsp; File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked&nbsp; File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked&nbsp; File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module&nbsp; File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed&nbsp; File "F:\djangoproject\blogproject\blog\models.py", line 2, in &lt;module&gt;&nbsp; &nbsp; from django.conyrib.auth.models import User&nbsp;</p><p>ModuleNotFoundError: No module named 'django.conyrib'<br></p><p><br></p><p>求教~</p><p>另外，我是Django2.0版本，之前按你的方法，并没有将界面改成中文。。。请问是什么情况</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2187"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2188">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/35491043?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Blake Peng
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Blake Peng
        

  </header>
  <div class="comment-body">
    <p>没关系了~问题已经解决了</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2188"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2157">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/26391392?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Amber
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>sorry，重来一遍</p><p>在输入了&nbsp;</p><pre><code class="lang-python">from blog.models import Category, Tag, Post<br />from django.utils import timezone&nbsp;<br />from django.contrib.auth.models import User &gt;&gt;&gt; user = User.object.get(user = 'myuser')<br></code></pre><pre><code class="lang-python">django.core.exceptions.FieldError: Cannot resolve keyword 'user' into field. Choices are: date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, password, post, user_permissions, username<br></code></pre>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2157"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2158">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Amber
        

  </header>
  <div class="comment-body">
    <p>你的&nbsp;User 模型中没有定义 user 这个属性吧？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2158"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2156">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/26391392?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Amber
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}user = User.objects.get(user = 'myuser')<br></p><p>然后出错</p><p>p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}span.s1 {font-variant-ligatures: no-common-ligatures}&nbsp;"Choices are: %s" % (name, ", ".join(available)))django.core.exceptions.FieldError: Cannot resolve keyword 'user' into field. Choices are: date_joined, email, first_name, groups, id, is_active, is_staff, is_superuser, last_login, last_name, logentry, password, post, user_permissions, username<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2156"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2132">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax3.sinaimg.cn/crop.0.0.996.996.180/c5c5ffa7ly8fftxrbpw2jj20ro0ron16.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">阿芽今天很元气
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主，运行python3 manage.py makemigrations 命令的时候报错了==结尾是这样的 SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc7 in position 14: invalid continuation byte &nbsp;我在models里面加了# coding: utf-8和没加都是一样的结果。我的Python是3.6.4的 Django是1.10.6的<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，4 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2132"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2134">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/7478804?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">hopeknow
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">阿芽今天很元气
        

  </header>
  <div class="comment-body">
    <p>&nbsp;编译的py文件保存时选择utf-8格式！应该是文本编辑器保存时默认为其它格式了。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，4 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2134"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2113">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/12111609?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">量飞
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>这里可以安装 pip install&nbsp;ipython 这个库，使交互操作更加智能。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2113"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2053">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax1.sinaimg.cn/crop.0.0.996.996.180/e894259aly8fi81ddo7nuj20ro0rogn0.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">小Q营姐
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>真得非常感谢博主的博文，给了我很大帮助。</p><p>我的blog和blogproject文件夹下均有__pycache__文件夹，并且blogproject文件夹下的__pycache__在push时不能为.gitignore文件所屏蔽，想问一下为什么？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2053"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2065">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/14370835?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Anderson Shao
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">小Q营姐
        

  </header>
  <div class="comment-body">
    <p>可以屏蔽，你的.gitignore设置错误<br><br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2065"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2250">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/31262495?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">mar-zou
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">小Q营姐
        

  </header>
  <div class="comment-body">
    <p>你需要清git缓存</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月，4 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2250"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2001">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/18026135?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">nordwind80
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主你好，我是在Django 2.0上跟着你的教程学习的。当我执行&nbsp;python3 manage.py makemigrations 命令时总是报错，能给我些帮助嘛？</p><p>SystemCheckError: System check identified some issues:ERRORS:blog.Post.author: (fields.E300) Field defines a relation with model 'blog.User', which is either not installed, or is abstract.blog.Post.author: (fields.E307) The field blog.Post.author was declared with a lazy reference to 'blog.user', but app 'blog' doesn't provide model 'user'.<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2001"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2006">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">nordwind80
        

  </header>
  <div class="comment-body">
    <p>似乎是你的 user 对象关联有问题，能否提供你的 models 相关代码？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2006"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2117">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/32010651?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">piedpiper77
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>博主你好，我和这个小伙伴的问题一样，不知道您有解决的办法 了嘛？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2117"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2227">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/11845936?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">fans
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">piedpiper77
        

  </header>
  <div class="comment-body">
    <p>需要这样添加外键：</p><p>category = models.ForeignKey(Category, on_delete=models.CASCADE)<br></p><p>添加on_delete参数，原因还没搞懂。。。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2227"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1832">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/33719428?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">xushuangang
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>请问下&nbsp; 您在数据添加时Post与Category有外键关系，直接删除Post为什么没有报错,这样会把所有的关联全部删除</p><p>个人理解&nbsp;应该是先删除Category的信息，然后再删除Post的信息</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1832"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1851">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">xushuangang
        

  </header>
  <div class="comment-body">
    <p>django 对数据库外键的删除就是层级删除，所有关联的数据都会删掉，这样可以保证数据的一致性。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1851"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2177">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/7949424?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Junhao Cai
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">xushuangang
        

  </header>
  <div class="comment-body">
    <p>Post与Category有外键关系，准确的说是多对一的关系，所以删除Post不会对Category有影响，相反，删除Category会把对应的所有Post级联删除(on_delete=models.CASCADE)。<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2177"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1826">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/7594150?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">rookie250
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>为什么叫迁移数据库？ 不是用orm建数据表么？<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1826"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1852">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">rookie250
        

  </header>
  <div class="comment-body">
    <p>migrate 一般被翻译作迁移了，我想应该是这样，术语不重要，理解意思就好。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1852"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1868">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/7594150?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">rookie250
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>好的 谢谢</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1868"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1785">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/33026785?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">NiceAir
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>求助： 我做完models.py后运行python manage.py makemigrations , 结果报错：</p><p>Traceback (most recent call last):&nbsp; File "manage.py", line 22, in &lt;module&gt;&nbsp; &nbsp; execute_from_command_line(sys.argv)&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line&nbsp; &nbsp; utility.execute()&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\core\management\__init__.py", line 359, in execute&nbsp; &nbsp; self.fetch_command(subcommand).run_from_argv(self.argv)&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\core\management\base.py", line 305, in run_from_argv&nbsp; &nbsp; self.execute(*args, **cmd_options)&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\core\management\base.py", line 356, in execute&nbsp; &nbsp; output = self.handle(*args, **options)&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\core\management\commands\makemigrations.py", line 167, in handle&nbsp; &nbsp; migration_name=self.migration_name,&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\db\migrations\autodetector.py", line 47, in changes&nbsp; &nbsp; changes = self._detect_changes(convert_apps, graph)&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\db\migrations\autodetector.py", line 132, in _detect_changes&nbsp; &nbsp; self.old_apps = self.from_state.concrete_apps&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\db\migrations\state.py", line 180, in concrete_apps&nbsp; &nbsp; self.apps = StateApps(self.real_apps, self.models, ignore_swappable=True)&nbsp; File "E:\python\PlaceOfLoading\lib\site-packages\django\db\migrations\state.py", line 249, in __init__&nbsp; &nbsp; raise ValueError("\n".join(error.msg for error in errors))ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'users.user', but app 'users' isn't installed.<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1785"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1790">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">NiceAir
        

  </header>
  <div class="comment-body">
    <p>show me some code</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1790"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2137">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/34832759?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">jingwz125
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">NiceAir
        

  </header>
  <div class="comment-body">
    <p>请问一下，你的问题解决了吗，谢谢！<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2137"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1752">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/default/images/default_avatar_male_180.gif"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">阿四925
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>&nbsp; &nbsp; 求解为什么执行python manage.py makemigrations时提醒No change detected。难道是数据模型建的时候出问题了？</p><p>&nbsp; &nbsp; 问题补充：尝试执行了python manage.py migrate.提示APP'your app name could not be found'。执行python manage.py makemigrations --empty yourappname提示No migration to apply</p><hr>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1752"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1761">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">阿四925
        

  </header>
  <div class="comment-body">
    <p>说明你已经生成了migrations文件，运行 migrate 命令就可以了。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1761"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1699">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.56.127.318.318.180/0062ORz3jw8epzgvm4n6mj30bz0fxjs7.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Y才小圣
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style=""><br>为 3 个模型分别增加一个&nbsp;__str__&nbsp;方法后，再重新运行&nbsp;python manage.py shell&nbsp;后报错<br></p><p style="">(blogproject_env) e:\Django\workspace\blogproject&gt;python manage.py shell&nbsp;</p><p style="">Traceback (most recent call last):&nbsp;&nbsp;</p><p style="">File "manage.py", line 22, in &lt;module&gt;&nbsp; &nbsp; execute_from_command_line(sys.argv)&nbsp;&nbsp;</p><p style="">File "E:\Django\blogproject_env\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line&nbsp; &nbsp; utility.execute()&nbsp;&nbsp;</p><p style="">File "E:\Django\blogproject_env\lib\site-packages\django\core\management\__init__.py", line 341, in execute&nbsp; &nbsp; django.setup()&nbsp;&nbsp;</p><p style="">File "E:\Django\blogproject_env\lib\site-packages\django\__init__.py", line 27, in setup&nbsp; &nbsp; apps.populate(settings.INSTALLED_APPS)&nbsp;&nbsp;</p><p style="">File "E:\Django\blogproject_env\lib\site-packages\django\apps\registry.py", line 108, in populate&nbsp; &nbsp; app_config.import_models(all_models)&nbsp;&nbsp;</p><p style="">File "E:\Django\blogproject_env\lib\site-packages\django\apps\config.py", line&nbsp;199, in import_models&nbsp; &nbsp; self.models_module = import_module(models_module_name)&nbsp;&nbsp;</p><p style="">File "E:\Python363\lib\importlib\__init__.py", line 126, in import_module&nbsp; &nbsp; return _bootstrap._gcd_import(name[level:], package, level)&nbsp;&nbsp;</p><p style="">File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import&nbsp;&nbsp;</p><p style="">File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load&nbsp;&nbsp;</p><p style="">File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked&nbsp;</p><p style="">&nbsp;File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked&nbsp;&nbsp;</p><p style="">File "&lt;frozen importlib._bootstrap_external&gt;", line 674, in exec_module&nbsp; File "&lt;frozen importlib._bootstrap_external&gt;", line 781, in get_code&nbsp;&nbsp;</p><p style="">File "&lt;frozen importlib._bootstrap_external&gt;", line 741, in source_to_code&nbsp;&nbsp;</p><p style="">File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed&nbsp; File "e:\Django\workspace\blogproject\blog\models.py", line 20&nbsp; &nbsp;&nbsp;</p><p style=""><span style="color: rgb(227, 55, 55);">def __unicode__(self):&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p><p style="margin-left: 160px;"><span style="color: rgb(227, 55, 55);">^TabError: inconsistent use of tabs and spaces in indentation</span></p><p style="margin-left: 160px;">目前的python版本是python3.6.3.。。。。难道我这边不能添加这个方法吗？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1699"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1706">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Y才小圣
        

  </header>
  <div class="comment-body">
    <p>TabError: inconsistent use of tabs and spaces in indentation：不要混用 tab 和 空格用于缩进。<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1706"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1686">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.56.127.318.318.180/0062ORz3jw8epzgvm4n6mj30bz0fxjs7.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Y才小圣
          
        </span>
    
  </header>
  <div class="comment-body">
    <p># coding: utf-8&nbsp;</p><p>from django.db import models&nbsp;</p><p>from django.contrib.auth.models import User&nbsp;</p><p>from django.utils.six import python_2_unicode_compatible</p><p>&nbsp;#python_2_unicode_compatible 装饰器用于兼容 Python2&nbsp;</p><p>@python_2_unicode_compatible&nbsp;</p><p>class Category(models.Model):&nbsp;</p><p style="margin-left: 40px;">&nbsp;name = models.CharField(max_length=100)&nbsp;</p><p style="margin-left: 40px;">&nbsp;def __str__(self):&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p style="margin-left: 80px;">return self.name&nbsp;</p><p>&nbsp;@python_2_unicode_compatible	class Tag(models.Model):&nbsp;</p><p style="margin-left: 40px;">&nbsp;name = models.CharField(max_length=100)&nbsp;</p><p style="margin-left: 40px;">&nbsp;def __str__(self):&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p style="margin-left: 80px;">return self.name&nbsp;</p><p>&nbsp;@python_2_unicode_compatible	</p><p>&nbsp;class Post(models.Model):&nbsp;</p><p style="margin-left: 40px;">&nbsp;title = models.CharField(max_length=70)</p><p style="margin-left: 40px;">&nbsp;body = models.TextField()</p><p style="margin-left: 40px;">&nbsp;created_time = models.DateTimeField()&nbsp;</p><p style="margin-left: 40px;">&nbsp;modified_time = models.DateTimeField()&nbsp;</p><p style="margin-left: 40px;">&nbsp;excerpt = models.CharField(max_length=200,blank=True)&nbsp;</p><p style="margin-left: 40px;">&nbsp;category = models.ForeignKey(Category)	</p><p style="margin-left: 40px;">tags = models.ManyToManyField(Tag,blank=True)&nbsp;</p><p style="margin-left: 40px;">&nbsp;author = models.ForeignKey(User)&nbsp;</p><p style="margin-left: 40px;">&nbsp;def __str__(self):&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p style="margin-left: 80px;">return self.title</p><p style="margin-left: 80px;">再次运行python3 manage.py shell的时候，报错</p><p style="margin-left: 80px;">&nbsp;File "E:\Django\workspace\blogproject\blog\models.py", line 12&nbsp; &nbsp;</p><p style="margin-left: 80px;">return self.name</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1686"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1687">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.56.127.318.318.180/0062ORz3jw8epzgvm4n6mj30bz0fxjs7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Y才小圣
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Y才小圣
        

  </header>
  <div class="comment-body">
    <p>当我把str方法删除，重新运行了一遍</p><p>&gt;&gt;&gt; from blog.models import Category, Tag, Post&nbsp;</p><p>&gt;&gt;&gt; from django.utils import timezone&nbsp;</p><p>&gt;&gt;&gt; from django.contrib.auth.models import User</p><p>&nbsp;&gt;&gt;&gt; user = User.objects.get(username='Cxs')</p><p>&nbsp;&gt;&gt;&gt; c = Category.objects.get(name='category test')</p><p>&nbsp;&gt;&gt;&gt; p = Post(title='title test', body='body test', created_time=timezone.now(),modified_time=timezone.now(), category=c, author=user)&nbsp;</p><p>&gt;&gt;&gt; p.save()<br></p><p>发现了新的错误</p><p>(blogproject_env) E:\Django\workspace\blogproject&gt;python3 manage.py shellPython 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32Type "help", "copyright", "credits" or "license" for more information.(InteractiveConsole)&nbsp;</p><p>&gt;&gt;&gt; Category.objects.all()&nbsp;</p><p>Traceback (most recent call last):&nbsp;&nbsp;</p><p>File "&lt;console&gt;", line 1, in &lt;module&gt;&nbsp;</p><p>NameError: name 'Category' is not defined&nbsp;</p><p>&gt;&gt;&gt; p = Post.objects.get(title='title test')&nbsp;</p><p>Traceback (most recent call last):&nbsp;&nbsp;</p><p>File "&lt;console&gt;", line 1, in &lt;module&gt;&nbsp;</p><p>NameError: name 'Post' is not defined&nbsp;</p><p>&gt;&gt;&gt; p = Post.objects.get(title='title test')&nbsp;</p><p>Traceback (most recent call last):&nbsp;</p><p>&nbsp;File "&lt;console&gt;", line 1, in &lt;module&gt;&nbsp;</p><p>NameError: name 'Post' is not defined<br></p><p>好难搞，求解！！！我会不会就卡在这儿了？？？？？？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1687"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1690">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Y才小圣
        

  </header>
  <div class="comment-body">
    <p>从你的错误来看，好像是因为你没有在命令栏引入 Post 和 Category，重新导入后再试一次。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1690"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1698">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.56.127.318.318.180/0062ORz3jw8epzgvm4n6mj30bz0fxjs7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Y才小圣
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>为 3 个模型分别增加一个&nbsp;__str__&nbsp;方法后，再重新运行&nbsp;python manage.py shell&nbsp;进入 Shell就开始报错了，目前的python版本是python3.6.3<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1698"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1713">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.56.127.318.318.180/0062ORz3jw8epzgvm4n6mj30bz0fxjs7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Y才小圣
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Y才小圣
        

  </header>
  <div class="comment-body">
    <p>感觉自己好蠢啊！！！这个问题卡了几天！！！！还有我用notepad++，写的，编辑器有什么好的推荐吗？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1713"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1751">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/default/images/default_avatar_male_180.gif"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">阿四925
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Y才小圣
        

  </header>
  <div class="comment-body">
    <p>我也用的notepad++,我朋友用的pycharm。感觉不出来太大的区别</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1751"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1937">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/12670670?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">jing.wang
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Y才小圣
        

  </header>
  <div class="comment-body">
    <p>用　vim　纯文本编辑器　没有其他的毛病，只用专心代码就 ok 了</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1937"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1636">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/12780752?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">HelloWorld
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>使用Pycharm编码，直接tests.py编写插入数据，报错：</p><p>django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.<br></p><p>说是settings的原因：修改：</p><p>import os&nbsp;</p><p>import django</p><p>&nbsp;os.environ.update({"DJANGO_SETTINGS_MODULE": "config.settings”})<br></p><p>django.setup()</p><p>然后运行，还是报错:</p><p>raise AppRegistryNotReady("Apps aren't loaded yet.")django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.<br></p><p>搜了好久都是说diango没有setup原因，但是我执行了。请博主详解</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1636"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1637">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">HelloWorld
        

  </header>
  <div class="comment-body">
    <p>这个问题我没有遇到过，但报错信息提示你没有指定django加载的settings文件，需要在环境变量里配置DJANGO_SETTINGS_MODULE为需要加载的settings文件，例如linux下：$:export&nbsp;DJANGO_SETTINGS_MODULE=config.settings</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1637"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1643">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/12780752?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">HelloWorld
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>这个配置了主要是<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1643"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1644">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/12780752?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">HelloWorld
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p><img alt="Image" src="http://img.blog.csdn.net/20160807190643964" width="1092" height="749"><br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1644"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1645">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/12780752?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">HelloWorld
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>然后使用命令行的方式是可以正确执行的</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1645"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1650">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">HelloWorld
        

  </header>
  <div class="comment-body">
    <p>那应该是pycharm配置问题了，查查文档吧，这个问题我没遇到过了。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1650"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1612">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.119.0.283.283.180/a0358d5agw1er3b1vhkkkj20ei07wwf7.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">HYDE_HIDE_
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>您好，我在取数据的时候，在model.py添加了博客的代码（代码是直接复制粘贴），还是不能显示str方法返回的内容。</p><p>Python是3.6.3，Django是1.11.</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1612"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1613">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.119.0.283.283.180/a0358d5agw1er3b1vhkkkj20ei07wwf7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">HYDE_HIDE_
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">HYDE_HIDE_
        

  </header>
  <div class="comment-body">
    <p>您好 已经解决了 删除装饰器就可以</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1613"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1700">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.56.127.318.318.180/0062ORz3jw8epzgvm4n6mj30bz0fxjs7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Y才小圣
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">HYDE_HIDE_
        

  </header>
  <div class="comment-body">
    <p style="">问一下，这个问题你是这么解决的？下面是我的代码：</p><p style=""># coding: utf-8</p><p style="">&nbsp;from django.db import models&nbsp;</p><p style="">from django.db import models&nbsp;</p><p style="">from django.contrib.auth.models import User&nbsp;</p><p style="">from django.utils.six import python_2_unicode_compatible&nbsp;</p><p style=""><br></p><p style="">&nbsp;# python_2_unicode_compatible 装饰器用于兼容 Python2</p><p style="">&nbsp;#@python_2_unicode_compatible&nbsp;</p><p style="">class Category(models.Model):&nbsp; &nbsp;&nbsp;</p><p style="margin-left: 40px;">&nbsp;name = models.CharField(max_length=100)&nbsp;</p><p style="margin-left: 40px;">&nbsp;def __str__(self):&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p style="margin-left: 80px;">return self.name&nbsp;</p><p style="">&nbsp;@python_2_unicode_compatible&nbsp;</p><p style="">class Tag(models.Model):&nbsp; &nbsp;&nbsp;</p><p style="margin-left: 40px;">name = models.CharField(max_length=100)	</p><p style="margin-left: 40px;">def __str__(self):&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p style="margin-left: 80px;">return self.name&nbsp;</p><p style="">#@python_2_unicode_compatible&nbsp;</p><p style="">class Post(models.Model):&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p style="margin-left: 40px;">title = models.CharField(max_length=70)&nbsp;</p><p style="margin-left: 40px;">body = models.TextField()&nbsp; &nbsp; &nbsp;</p><p style="margin-left: 40px;">created_time = models.DateTimeField()&nbsp; &nbsp;&nbsp;</p><p style="margin-left: 40px;">modified_time = models.DateTimeField()&nbsp; &nbsp;&nbsp;</p><p style="margin-left: 40px;">excerpt = models.CharField(max_length=200, blank=True)&nbsp; &nbsp; &nbsp;</p><p style="margin-left: 40px;">category = models.ForeignKey(Category)&nbsp; &nbsp;</p><p style="margin-left: 40px;">tags = models.ManyToManyField(Tag, blank=True)&nbsp; &nbsp; &nbsp;</p><p style="margin-left: 40px;">author = models.ForeignKey(User)&nbsp;</p><p style="margin-left: 40px;">def __str__(self):&nbsp;</p><p style="margin-left: 40px;">&nbsp;&nbsp; &nbsp; &nbsp; return self.title</p><p style="margin-left: 40px;">我这边是直接不能重新运行python manage.py shell</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1700"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1536">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax3.sinaimg.cn/default/images/default_avatar_male_180.gif"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">王老哥
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>前面都对,到这一步进行不下去了,求帮忙,如下所示:</p><p>&gt;&gt;&gt; from django.utils import timezone</p><p>&nbsp;&gt;&gt;&gt; from django.contrib.auth.models import User&nbsp;</p><p>&gt;&gt;&gt; user = User.objects.get(username='myuser')</p><p>&nbsp;Traceback (most recent call last):&nbsp; File "&lt;console&gt;", line 1, in &lt;module&gt;&nbsp; File "D:\wpy\learn_log\ll_env\lib\site-packages\django\db\models\manager.py", line 85, in manager_method&nbsp; &nbsp; return getattr(self.get_queryset(), name)(*args, **kwargs)&nbsp; File "D:\wpy\learn_log\ll_env\lib\site-packages\django\db\models\query.py", line 385, in get&nbsp; &nbsp; self.model._meta.object_namedjango.contrib.auth.models.DoesNotExist: User matching query does not exist.</p><p>&nbsp;&gt;&gt;&gt;<br>请问怎么回事啊?谢谢!!!</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1536"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1537">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">王老哥
        

  </header>
  <div class="comment-body">
    <p><b>User matching query does not exist</b><br></p><p>你需要先创建用户名为&nbsp;myuser 的用户</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1537"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1479">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.0.0.512.512.180/a4caec8fjw8eqpgvtnxkmj20e80e83z9.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">-冯龙
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style="">OperationalError: no such table: blog_category&nbsp; 请问这是什么意思 为什么会有这样的错误<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1479"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1499">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/25856599?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">莫世威
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">-冯龙
        

  </header>
  <div class="comment-body">
    <p>没有查找到你的blog_category数据表，请确认你是否进行了数据迁移，也就是migrate，去查看一下你的数据库中是否有这张表，希望对你有帮助</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1499"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1510">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.0.0.512.512.180/a4caec8fjw8eqpgvtnxkmj20e80e83z9.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">-冯龙
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">莫世威
        

  </header>
  <div class="comment-body">
    <p style="">好像我之前在数据迁移那里出了问题，我重新做了一遍就好了，谢谢你~<br><br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1510"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1437">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/23394916?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">KingsyWu
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style="">TypeError: 'modified_time' is an invalid keyword argument for this function<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1437"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1438">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/23394916?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">KingsyWu
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">KingsyWu
        

  </header>
  <div class="comment-body">
    <p style="">我敲错了<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1438"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1436">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/23394916?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">KingsyWu
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style="">我用# coding: utf-8报错，</p><p style="">改成了# coding=utf-8就可以了<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1436"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1422">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/24824234?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">parsonscp
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>post保存时出现异常pytz.exceptions.UnknownTimeZoneError: 'asia/shanghai'怎么解决啊<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1422"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1429">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">parsonscp
        

  </header>
  <div class="comment-body">
    <p>尝试改为大写试试 Asia/Shanghai</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1429"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1431">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/default/images/default_avatar_male_180.gif"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">华智锋范
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">parsonscp
        

  </header>
  <div class="comment-body">
    <p>Asia/Shanghai</p><p>注意大小写</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1431"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1434">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/24824234?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">parsonscp
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>解决了 不是大小写问题 要在settings.py文件中引入pytz模块</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1434"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1376">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax3.sinaimg.cn/crop.0.0.512.512.180/006DXHgcly8fg73djwwp0j30e80e8gm5.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">NovAa__
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>c = Category(name='category test')<br></p><p>这一步报错是为什么。。</p><p>TypeError: 'name' is an invalid keyword argument for this function<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，4 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1376"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1378">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/31658250?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">mamami
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">NovAa__
        

  </header>
  <div class="comment-body">
    <p>c = Category.objects.get(name='category test')<br></p><p>应该是这个</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，4 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1378"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2228">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/11845936?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">fans
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">mamami
        

  </header>
  <div class="comment-body">
    <p>这个是读数据吧，LS是想保存数据，下边会接c.save()</p><p>我也是卡到这了，不过我自己写sql插入了一条数据，解决了报错问题，但是现在是保存的都是空值！</p><p>&nbsp;sqlite&gt; select * from myapp_tag;</p><p>&nbsp;id|name&nbsp;</p><p>&nbsp;1|test</p><p>&nbsp;&nbsp;2|</p><p>&nbsp;sqlite&gt;&nbsp;<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2228"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1336">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20694632?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Annihilater
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style="">在blog/models.py写入(python2环境)</p><p style="">&nbsp;from django.utils.six import python_2_unicode_compatible&nbsp; &nbsp;&nbsp;</p><p style="margin-left: 40px;">def _unicode_(self): &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p><p style="margin-left: 80px;">return self.name &nbsp;保存之后，再次运行</p><p style="margin-left: 80px;">Post.objects.get(title='title test')显示结果仍然是&lt;Post: Post object&gt;</p><p style="margin-left: 80px;">并不显示&lt;Post: title test&gt;，求解释？？？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1336"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1337">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20694632?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Annihilater
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Annihilater
        

  </header>
  <div class="comment-body">
    <p style="">问题解决了，__unicode__应该是两个下划线，我只用了一个。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1337"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1287">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20694632?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Annihilater
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style="">输入python manage.py makemigrations</p><p style="">得到django.db.utils.DatabaseError: database disk image is malformed</p><p style="">这个数据库磁盘映像格式错误是什么鬼？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1287"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1289">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Annihilater
        

  </header>
  <div class="comment-body">
    <p>删掉数据库重新试一下</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1289"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1294">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20694632?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Annihilater
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p style="">运行python manage.py flush</p><p style="">还是得到django.db.utils.DatabaseError: database disk image is malformed</p><p style="">求解答</p><p style="">删除数据库怎么删？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1294"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1295">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Annihilater
        

  </header>
  <div class="comment-body">
    <p>你是 sqlite3 么，直接把项目下 db.sqlite3 文件删了即可。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1295"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1335">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20694632?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Annihilater
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p style="">是的 &nbsp; 删除重新来一遍就好了 &nbsp;谢谢</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1335"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1255">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax1.sinaimg.cn/crop.0.0.664.664.180/63fcc27cly8fho9zhlopzj20ig0igjsn.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">苏柠紫
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>&nbsp; File "&lt;frozen importlib._bootstrap_external&gt;", line 674, in exec_module&nbsp; File "&lt;frozen importlib._bootstrap_external&gt;", line 781, in get_code&nbsp; File "&lt;frozen importlib._bootstrap_external&gt;", line 741, in source_to_code&nbsp; File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed&nbsp; File "D:\blogproject\blog\models.py", line 48&nbsp; &nbsp; def __str__(self):&nbsp; &nbsp; &nbsp; ^SyntaxError: invalid syntax<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1255"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1244">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/16384951?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">heidanchaofanhei
          
        </span>
    
  </header>
  <div class="comment-body">
    已经解决了，谢谢，因为我以为“myuser”是随便填的呢，因为我的数据库名字是“admin”，所以这个“myuser”应该对应改成admin。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1244"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1175">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/20558295?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Ethan
          
        </span>
    
  </header>
  <div class="comment-body">
    博主，您好。我在运行您的demo时，迁移数据库那步<br />(blogproject_env)edu@edu-T:/mnt/hgfs/GitHub/django-blog-tutorial$ python3 manage.py migrate<br />Failed to import the site module<br />Traceback (most recent call last):<br />  File "/home/edu/share/Envs/blogproject_env/lib/python3.5/site.py", line 67, in <module><br />    import os<br />  File "/home/edu/share/Envs/blogproject_env/lib/python3.5/os.py", line 708, in <module><br />    from _collections_abc import MutableMapping<br />ImportError: No module named '_collections_abc'<br />出现这个。<br />请问怎么办。那个模块是需要安装吗？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1175"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1177">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Ethan
        

  </header>
  <div class="comment-body">
    看着像是 python自带的模块，检查一下python是否安装正确，以及python路径的设置等等。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1177"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1173">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/31400115?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">kong5kong
          
        </span>
    
  </header>
  <div class="comment-body">
    博主，这是什么原因<br />Traceback (most recent call last):<br />  File "manage.py", line 22, in <module><br />    execute_from_command_line(sys.argv)<br />  File "c:\xuniji\lib\site-packages\django\core\management\__init__.py", line 36<br />7, in execute_from_command_line<br />    utility.execute()<br />  File "c:\xuniji\lib\site-packages\django\core\management\__init__.py", line 31<br />6, in execute<br />    settings.INSTALLED_APPS<br />  File "c:\xuniji\lib\site-packages\django\conf\__init__.py", line 53, in __geta<br />ttr__<br />    self._setup(name)<br />  File "c:\xuniji\lib\site-packages\django\conf\__init__.py", line 41, in _setup<br /><br />    self._wrapped = Settings(settings_module)<br />  File "c:\xuniji\lib\site-packages\django\conf\__init__.py", line 97, in __init<br />__<br />    mod = importlib.import_module(self.SETTINGS_MODULE)<br />  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module<br />    __import__(name)<br />  File "C:\blogproject\blogproject\settings.py", line 50<br />SyntaxError: Non-ASCII character '\xe6' in file C:\blogproject\blogproject\setti<br />ngs.py on line 50, but no encoding declared; see http://python.org/dev/peps/pep-<br />0263/ for details
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1173"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1179">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">kong5kong
        

  </header>
  <div class="comment-body">
    编码问题，如果你使用 py2，需要在文件开头部分做编码说明。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1179"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1164">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/16384951?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">heidanchaofanhei
          
        </span>
    
  </header>
  <div class="comment-body">
    请教一个问题：<br />>>> from blog.models import Category, Tag, Post<br />>>> from django.utils import timezone<br />>>> from django.contrib.auth.models import User<br />>>> user = User.objects.get(username='myuser')<br /><br /><br />我输入完上面代码，然后就报错了，报错内容：<br />django.contrib.auth.models.DoesNotExist: User matching query does not exist.<br /><br />大家帮忙看一下，谢谢，现在卡在这了
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1164"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1181">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">heidanchaofanhei
        

  </header>
  <div class="comment-body">
    首先需要创建一个名为 myuser 的用户才能从数据库取值。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1181"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c920">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax3.sinaimg.cn/crop.0.0.1328.1328.180/c574a95cly8ffysjwe0fgj210w10wjvh.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">霜华长安
          
        </span>
    
  </header>
  <div class="comment-body">
    输入python manage.py makemigrations后显示为这个<br />Traceback (most recent call last):<br />  File "manage.py", line 15, in <module><br />    execute_from_command_line(sys.argv)<br />  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\sit<br />e-packages\django-2.0-py3.5.egg\django\core\management\__init__.py", line 365, i<br />n execute_from_command_line<br />    utility.execute()<br />  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\sit<br />e-packages\django-2.0-py3.5.egg\django\core\management\__init__.py", line 341, i<br />n execute<br />    django.setup()<br />  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\sit<br />e-packages\django-2.0-py3.5.egg\django\__init__.py", line 24, in setup<br />    apps.populate(settings.INSTALLED_APPS)<br />  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\sit<br />e-packages\django-2.0-py3.5.egg\django\apps\registry.py", line 112, in populate<br />    app_config.import_models()<br />  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\sit<br />e-packages\django-2.0-py3.5.egg\django\apps\config.py", line 198, in import_mode<br />ls<br />    self.models_module = import_module(models_module_name)<br />  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\lib\imp<br />ortlib\__init__.py", line 126, in import_module<br />    return _bootstrap._gcd_import(name[level:], package, level)<br />  File "<frozen importlib._bootstrap>", line 985, in _gcd_import<br />  File "<frozen importlib._bootstrap>", line 968, in _find_and_load<br />  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked<br />  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked<br />  File "<frozen importlib._bootstrap_external>", line 697, in exec_module<br />  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed<br />  File "C:\Users\Administrator\workspace\blogproject\blog\models.py", line 27, i<br />n <module><br />    class Post(models.Model):<br />  File "C:\Users\Administrator\workspace\blogproject\blog\models.py", line 54, i<br />n Post<br />    category = models.ForeignKey(Category)<br />TypeError: __init__() missing 1 required positional argument: 'on_delete'
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/920"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c925">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">霜华长安
        

  </header>
  <div class="comment-body">
    TypeError: __init__() missing 1 required positional argument: 'on_delete'<br /><br />Foreinkey 可以设置 on_delete=models.CASCADE
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/925"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c808">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/20392551?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zhuxinxia1992
          
        </span>
    
  </header>
  <div class="comment-body">
    您好，python manage.py makemigrations 和 python manage.py migrate 显示No changes detected，No migrations to apply.而我的migrations文件夹只显示__init__.py文件，并没有其他文件。应该如何解决？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/808"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c810">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/20392551?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zhuxinxia1992
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">zhuxinxia1992
        

  </header>
  <div class="comment-body">
    忽略，已解决，原因是没有在setting.py加入‘blog’
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/810"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c791">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.996.996.180/a91386f8jw8fcxx9afhiwj20ro0rowg5.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">hello羊妹儿
          
        </span>
    
  </header>
  <div class="comment-body">
    您好，请问这个怎么处理，是错误吗，搜到的都和这个不太一样<br />>>> Post.objects.get(title='title test')<br />Traceback (most recent call last):<br />  File "<console>", line 1, in <module><br />  File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 85, inmanager_method<br />    return getattr(self.get_queryset(), name)(*args, **kwargs)<br />  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 384, in get<br />    (self.model._meta.object_name, num)<br />MultipleObjectsReturned: get() returned more than one Post -- it returned 2!
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/791"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c794">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">hello羊妹儿
        

  </header>
  <div class="comment-body">
    你这个因为有多条记录返回，所以使用 get 会抛出异常。可以删掉重复记录，或者删掉全部数据按照教程重开。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/794"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c801">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.996.996.180/a91386f8jw8fcxx9afhiwj20ro0rowg5.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">hello羊妹儿
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    谢谢博主，比对了你的代码把测试的两个test删了，已经可以啦
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/801"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c718">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars4.githubusercontent.com/u/27217235?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Mr.Lv@Li
          
        </span>
    
  </header>
  <div class="comment-body">
    那个Category有object这个属性？我报错了额。。。<br />这是怎么回事呢？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/718"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c719">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars4.githubusercontent.com/u/27217235?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Mr.Lv@Li
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Mr.Lv@Li
        

  </header>
  <div class="comment-body">
    没有加s
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/719"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c714">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars4.githubusercontent.com/u/27217235?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Mr.Lv@Li
          
        </span>
    
  </header>
  <div class="comment-body">
    你好，原来是存在migrations\这个文件的，我不小心删掉了，现在再python manage.py makemigrations 和 python manage.py migrate 显示No changes detected，怎么办，没法完成接下来的工作了，还有我用到c.save(),出现了错误信息，怎么回事呢，麻烦博主了，谢谢。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/714"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c747">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Mr.Lv@Li
        

  </header>
  <div class="comment-body">
    只能够删掉全部 migrations 文件和数据库文件，然后重新生成。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/747"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c809">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/20392551?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zhuxinxia1992
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Mr.Lv@Li
        

  </header>
  <div class="comment-body">
    您好，请问您的问题解决了么？是如何解决的呢？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/809"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c812">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars4.githubusercontent.com/u/27217235?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Mr.Lv@Li
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">zhuxinxia1992
        

  </header>
  <div class="comment-body">
    我重建一个博客，按照上面的步骤，很快的，又能温故而知新，不在这些问题上钻牛角尖的浪费时间。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/812"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1412">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/30768687?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">ed2x
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Mr.Lv@Li
        

  </header>
  <div class="comment-body">
    <p>python manage.py makemigrations blog<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1412"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2230">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/30652324?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">y-xiang
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">ed2x
        

  </header>
  <div class="comment-body">
    <p>多谢老哥！</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2230"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c608">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.0.1080.1080.180/bea95d53jw8eyjdqymvo8j20u00u0myu.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">ShayChris
          
        </span>
    
  </header>
  <div class="comment-body">
    已经设置Post里的tag为blank=True，然后在命令行里p2 = Post(title = 'title test', body='body test', create_time=timezone.now(),modified_time=timezone.now(), category=c, author=user)成功，但是p2.save()时就出下面这个错误<br />django.db.utils.IntegrityError: NOT NULL constraint failed: blog_post.tag_id，求解，多谢多谢
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/608"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c609">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.0.1080.1080.180/bea95d53jw8eyjdqymvo8j20u00u0myu.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">ShayChris
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">ShayChris
        

  </header>
  <div class="comment-body">
    将tag加上之后就可以保存
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/609"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c611">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/26964030?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">rockfire
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">ShayChris
        

  </header>
  <div class="comment-body">
    tag=models.ManyToManyField(Tag,blank=True)<br />你是没加blank=True吧
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/611"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c612">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.0.1080.1080.180/bea95d53jw8eyjdqymvo8j20u00u0myu.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">ShayChris
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">rockfire
        

  </header>
  <div class="comment-body">
    class Post(models.Model):<br />    tag = models.ForeignKey(Tag, blank=True)<br />我是这样写的，应该没问题吧？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/612"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2225">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/33972865?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zabida
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">ShayChris
        

  </header>
  <div class="comment-body">
    <p>老铁，一样的问题啊</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2225"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c564">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva4.sinaimg.cn/crop.0.0.180.180.180/0065bw4Ljw8fbz9lj1m3tj3050050t8p.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">宝子要加油
          
        </span>
    
  </header>
  <div class="comment-body">
    添加了 _str_之后依旧无法显示数据的具体内容。我用的是Python3.6, Django 1.11, 之前在官网教程练习的时候，这个功能还是好使的，不知道为啥现在突然怎么样都显示不出来了。求教！
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/564"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c575">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">宝子要加油
        

  </header>
  <div class="comment-body">
    有两个下划线 __str__
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/575"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c527">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.168.27.540.540.180/b5fcb471jw1ej66ey2lkzj20nu0fu44e.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">AL拒绝拖延
          
        </span>
    
  </header>
  <div class="comment-body">
    >>> p = Post(title='title test', body='body test', created_time=timezone.now(), modified_time=timezone.now(), category=c, author=user)      写入语句时候,提示我TypeError: 'created_ti' is an invalid keyword argument for this function  求求求
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/527"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c528">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.168.27.540.540.180/b5fcb471jw1ej66ey2lkzj20nu0fu44e.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">AL拒绝拖延
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">AL拒绝拖延
        

  </header>
  <div class="comment-body">
    TypeError: 'created_time' is an invalid keyword argument for this function   这是报错  上面的  贴错了
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/528"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c529">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">AL拒绝拖延
        

  </header>
  <div class="comment-body">
    检查模型中 created time 是否拼错了。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/529"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c532">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.168.27.540.540.180/b5fcb471jw1ej66ey2lkzj20nu0fu44e.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">AL拒绝拖延
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    没有 拼错..我重新从你的代码里面 粘贴过去了  还是不行.... 我用的python3.6
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/532"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c534">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.168.27.540.540.180/b5fcb471jw1ej66ey2lkzj20nu0fu44e.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">AL拒绝拖延
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    帅哥,我知道怎么回事了   昨天我是表的 列created_time 拼写错了  然后我改了之后   我没有重新移数据库   然后运行写入Post(....)信息的时候 就会报上面的错...  这次出这个问题 基本上 这块算是懂了  谢谢哈
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/534"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c491">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax4.sinaimg.cn/crop.0.3.506.506.180/af87807fly8fh1cgkubolj20e20e875c.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">逐殇小彬
          
        </span>
    
  </header>
  <div class="comment-body">
    c = Category.objects.get(name='category test')  <br />报错：<br />DoesNotExist： Category matching query does not exist <br />----------这个是哪里有问题  求救
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/491"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c492">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">逐殇小彬
        

  </header>
  <div class="comment-body">
    这条记录不存在，先创建一条，再取。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/492"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c493">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax4.sinaimg.cn/crop.0.3.506.506.180/af87807fly8fh1cgkubolj20e20e875c.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">逐殇小彬
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    谢谢   遗漏了  <br />这边还有两个问题 麻烦了<br />1、python manage.py migrate news<br />报错  column slug is not unique   这个是什么原因？<br />2、这边想删除sqlite3的表 都是输入报错<br />Python manage.py dbshell<br />报错 You appear not tohave the sqlite3 program installed or on your path<br /><br />麻烦博主
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/493"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c494">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">逐殇小彬
        

  </header>
  <div class="comment-body">
    column slug is not unique 确保值唯一<br /><br />Python manage.py dbshell 你没有 sqlite3 客户端
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/494"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c320">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.180.180.180/5b6dbb47jw1e8qgp5bmzyj2050050aa8.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">天地之春
          
        </span>
    
  </header>
  <div class="comment-body">
    运行后，migrations没有001这个文件呢
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/320"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c321">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">天地之春
        

  </header>
  <div class="comment-body">
    具体情况是？没有把 blog 加入 settings.py?
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/321"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c325">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.180.180.180/5b6dbb47jw1e8qgp5bmzyj2050050aa8.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">天地之春
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    感谢 已经解决
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/325"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c214">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax1.sinaimg.cn/crop.0.0.1144.1144.180/006pY1Ayly8ff91frn95kj30vs0vs768.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">回不去的木木
          
        </span>
    
  </header>
  <div class="comment-body">
    忘记了设置的密码怎么找回来呢？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/214"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c215">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">回不去的木木
        

  </header>
  <div class="comment-body">
    重新创建一个 super user 吧。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/215"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c536">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/26964030?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">rockfire
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">回不去的木木
        

  </header>
  <div class="comment-body">
    python manage.py  changepassword <user_name>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/536"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c190">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax4.sinaimg.cn/default/images/default_avatar_male_180.gif"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">木瑾_37436
          
        </span>
    
  </header>
  <div class="comment-body">
    运行python manage.py makemigrations命令是报错：name "User" is not defined是怎么回事啊，要怎么处理
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/190"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c191">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax4.sinaimg.cn/default/images/default_avatar_male_180.gif"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">木瑾_37436
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">木瑾_37436
        

  </header>
  <div class="comment-body">
    已经好了，是开始是忘记import user了， 囧
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/191"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c549">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.180.180.180/66e873c6jw1e8qgp5bmzyj2050050aa8.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">刘智彬会灰
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">木瑾_37436
        

  </header>
  <div class="comment-body">
    一开始我也没import user，捣鼓了一大轮才发现是抄漏了。。。。。。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/549"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c71">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/28527786?v=3"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">liuchengfei
          
        </span>
    
  </header>
  <div class="comment-body">
    运行 c = Category.objects.get(name='category test')时报错，blog.models.MultipleObjectsReturned  : get()returned more than one Gategory--it returnde 3
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">11 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/71"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c74">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">liuchengfei
        

  </header>
  <div class="comment-body">
    这说明已经在数据库中存在多个这样的数据，所以用 get 就会报错，先调用 Category.objects.all().delete() 删掉重新添加一个。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">11 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/74"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c58">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/28527786?v=3"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">liuchengfei
          
        </span>
    
  </header>
  <div class="comment-body">
    为什么我输入ctrl+c，不能退出交互模式，而是提示keyboardinterrupt
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">11 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/58"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c60">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">liuchengfei
        

  </header>
  <div class="comment-body">
    多按几次应该就可以啦。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">11 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/60"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c72">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/15381809?v=3"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">gleesu
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">liuchengfei
        

  </header>
  <div class="comment-body">
    我在ubuntu下面也是这样，用ctrl+D就跳出来了。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">11 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/72"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c934">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/27881475?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zxt
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    博主，多按几次还是没用咋办
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/934"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c936">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">zxt
        

  </header>
  <div class="comment-body">
    。。ctrl+D，或者直接关了重开。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/936"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1088">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/31131565?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">IHaoMing
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">zxt
        

  </header>
  <div class="comment-body">
    exit()函数可以退出
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1088"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c37">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/26848875?v=3"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">tianjigor
          
        </span>
    
  </header>
  <div class="comment-body">
    py2.7，直接重写 <br />def __str__(self):<br />return self.name<br />就OK了
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">11 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/37"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
  
</div>
  </section>
</div>
  </div>

    </div>
  </div>
</section>
<footer class="bg-white py-5 mt-5 text-small text-muted">
  <div class="flex-center">
    <div>&copy; 2017 追梦人物的博客</div>
  </div>
  
  
  
</footer>
<script>
    $('[data-menu]').menu();

    var InterValObj; //timer变量，控制时间
    var curCount = 120;//当前剩余秒数

    $('#js-send').on('click', function (event) {
        var $this = $(this);
        var $targetURL = $this.attr('data-target');
        $.post(
            $targetURL,
            {email: $('#id_email').val()},
            function (data) {
                if (data.ok) {
                    $this.attr("disabled", "true");
                    $this.text("重新发送验证码" + "(" + curCount + ")");
                    InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                    $('.message')
                        .find('span')
                        .text(data.msg)
                } else {
                    $('.message').find('span').text(data.msg)
                }
            }
        );
        return false;
    });

    //timer处理函数
    function SetRemainTime() {
        if (curCount === 0) {
            window.clearInterval(InterValObj);//停止计时器
            $('#js-send').removeAttr("disabled");//启用按钮
            $('#js-send').text("重新发送验证码");
        }
        else {
            curCount--;
            $('#js-send').text("重新发送验证码" + "(" + curCount + ")");
        }
    }

    $('#js-submit').on('click', function (event) {
        var $this = $(this);
        var $form = $('.email-binding-form');
        var $targetURL = $form.attr('action');
        console.log($targetURL);

        $.post(
            $targetURL,
            {
                email: $('#id_email').val(),
                verification_code: $('#id_verification_code').val()
            },
            function (data) {
                if (data.ok) {
                    location.reload();
                } else {
                    $('.message')
                        .find('span')
                        .text(data.msg)
                }
            }
        );
        return false;
    });


    var editor = new Simditor({
        textarea: $('#id_comment'),
        placeholder: "提出你的见解...",
        toolbarFloat: false,
        cleanPaste: true,
        toolbar: [
            'bold',
            'italic',
            'underline',
            'strikethrough',
            'color',
            'ol',
            'ul',
            'blockquote',
            'code',
            'table',
            'link',
            'image',
            'hr'
        ]
    });
</script>


</body>
</html>